package com.yehuo.app.model;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class APP<T> implements Serializable {
    private Integer code;
    private String msg;
    private T result;

    public APP(String msg, T result) {
        this.code = 200;
        this.msg = msg;
        this.result = result;
    }

    public static <T> APP success(String msg, T result) {
        APP app = new APP();
        app.code = 200;
        app.msg = msg;
        app.result = result;
        return app;
    }

    public static <T> APP fail(String msg, T result) {
        APP app = new APP();
        app.code = 500;
        app.msg = msg;
        app.result = result;
        return app;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public T getResult() {
        return this.result;
    }

    public void setCode(final Integer code) {
        this.code = code;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }

    public void setResult(final T result) {
        this.result = result;
    }
}

